﻿using System;

namespace HslCommunication.Reflection
{
	/// <summary>
	/// 可以指定方法的权限内容，可以限定MQTT会话的ClientID信息或是UserName内容<br />
	///
	/// </summary>
	// Token: 0x0200010D RID: 269
	[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
	public class HslMqttPermissionAttribute : Attribute
	{
		/// <summary>
		/// ClientId的限定内容
		/// </summary>
		// Token: 0x17000514 RID: 1300
		// (get) Token: 0x060017AD RID: 6061 RVA: 0x0007880B File Offset: 0x00076A0B
		// (set) Token: 0x060017AE RID: 6062 RVA: 0x00078813 File Offset: 0x00076A13
		public string ClientID { get; set; }

		/// <summary>
		/// UserName的限定内容
		/// </summary>
		// Token: 0x17000515 RID: 1301
		// (get) Token: 0x060017AF RID: 6063 RVA: 0x0007881C File Offset: 0x00076A1C
		// (set) Token: 0x060017B0 RID: 6064 RVA: 0x00078824 File Offset: 0x00076A24
		public string UserName { get; set; }

		/// <summary>
		/// 检查当前的客户端ID是否通过
		/// </summary>
		/// <param name="clientID">ID信息</param>
		/// <returns>是否检测成功</returns>
		// Token: 0x060017B1 RID: 6065 RVA: 0x00078830 File Offset: 0x00076A30
		public virtual bool CheckClientID(string clientID)
		{
			bool flag = string.IsNullOrEmpty(this.ClientID);
			return flag || this.ClientID == clientID;
		}

		/// <summary>
		/// 检查当前的用户名是否通过
		/// </summary>
		/// <param name="name">用户名</param>
		/// <returns>是否检测成功</returns>
		// Token: 0x060017B2 RID: 6066 RVA: 0x00078864 File Offset: 0x00076A64
		public virtual bool CheckUserName(string name)
		{
			bool flag = string.IsNullOrEmpty(this.UserName);
			return flag || this.UserName == name;
		}
	}
}
